package com.aboo.action;

import com.aboo.api.StudentService;
import com.aboo.domain.Student;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/consumer")
public class ConsumerStudentAction {

    @Reference(group = "school", version = "1.0")
    private StudentService studentService01;

    @RequestMapping("/student01")
    public Map<String, Object> student01() {
        Map<String, Object> result = new HashMap<>(8);
        result.put("flag", "Y");
        result.put("desc", "这是一个dubbo消费者1.0测试");

        Student student = studentService01.getByName("Kabala");
        result.put("data", student);
        log.info(JSONObject.toJSONString(result));

        return result;
    }

}
